package com.ruoyi.bole.wechatSubscribe.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bole.wechatSubscribe.domain.BoleWechatSubscribeUser;
import com.ruoyi.bole.wechatSubscribe.service.IBoleWechatSubscribeUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信小程序订阅消息推送用户（关联用户）Controller
 * 
 * @author wujiale
 * @date 2025-07-26
 */
@RestController
@RequestMapping("/wechatSubscribe/info")
public class BoleWechatSubscribeUserController extends BaseController
{
    @Autowired
    private IBoleWechatSubscribeUserService boleWechatSubscribeUserService;

    /**
     * 查询微信小程序订阅消息推送用户（关联用户）列表
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoleWechatSubscribeUser boleWechatSubscribeUser)
    {
        startPage();
        List<BoleWechatSubscribeUser> list = boleWechatSubscribeUserService.selectBoleWechatSubscribeUserList(boleWechatSubscribeUser);
        return getDataTable(list);
    }

    /**
     * 导出微信小程序订阅消息推送用户（关联用户）列表
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:export')")
    @Log(title = "微信小程序订阅消息推送用户（关联用户）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoleWechatSubscribeUser boleWechatSubscribeUser)
    {
        List<BoleWechatSubscribeUser> list = boleWechatSubscribeUserService.selectBoleWechatSubscribeUserList(boleWechatSubscribeUser);
        ExcelUtil<BoleWechatSubscribeUser> util = new ExcelUtil<BoleWechatSubscribeUser>(BoleWechatSubscribeUser.class);
        util.exportExcel(response, list, "微信小程序订阅消息推送用户（关联用户）数据");
    }

    /**
     * 获取微信小程序订阅消息推送用户（关联用户）详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(boleWechatSubscribeUserService.selectBoleWechatSubscribeUserById(id));
    }

    /**
     * 新增微信小程序订阅消息推送用户（关联用户）
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:add')")
    @Log(title = "微信小程序订阅消息推送用户（关联用户）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoleWechatSubscribeUser boleWechatSubscribeUser)
    {
        return toAjax(boleWechatSubscribeUserService.insertBoleWechatSubscribeUser(boleWechatSubscribeUser));
    }

    /**
     * 修改微信小程序订阅消息推送用户（关联用户）
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:edit')")
    @Log(title = "微信小程序订阅消息推送用户（关联用户）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoleWechatSubscribeUser boleWechatSubscribeUser)
    {
        return toAjax(boleWechatSubscribeUserService.updateBoleWechatSubscribeUser(boleWechatSubscribeUser));
    }

    /**
     * 删除微信小程序订阅消息推送用户（关联用户）
     */
    @PreAuthorize("@ss.hasPermi('wechatSubscribe:info:remove')")
    @Log(title = "微信小程序订阅消息推送用户（关联用户）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boleWechatSubscribeUserService.deleteBoleWechatSubscribeUserByIds(ids));
    }
}
